﻿var bepop = bepop || {};
bepop.view = bepop.view || {};

bepop.view.init = function () {
	var navidation = document.getElementById("navTab");

	bepop.init(navidation, navigatonClick);

	function navigatonClick(e) {
		$(e.currentTarget).tab('show');
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
		bepop.view.dragdrop();
	};
};

bepop.view.popup = bepop.view.popup || {};

bepop.view.popup.showPopup = function(cover) {
	$('#modal').modal('show').width(cover.width);
};

bepop.view.common = bepop.view.common || {};

bepop.view.common.single = function (id, init) {
	var el = document.getElementById(id);
	if (typeof el == "undefined") {
		throw new Error("bepop.view.common.single: Invalid param arg.");
	}
	if (typeof init == "undefined") {
		return Boolean(el.getAttribute("init"));
	}
	el.setAttribute("init", init);
	return el;
};

bepop.view.dragdrop = function(e) {
	debugger;
	var maxFileSize = 1000000;
	var dropZone = $('.cover');

	if(!bepop.model.system.isDragAndDropSupported) {
		return;
	}

	dropZone[0].ondragover = function() {
		return false;
	};

	dropZone[0].ondragleave = function() {
		return false;
	};

	dropZone[0].ondrop = function(event) {
		event.preventDefault();
		debugger;
		var file = event.dataTransfer.files[0];
		if (file.size > maxFileSize) {
			return false;
		}
		return false;
	};
};